package com.example.demo.service;

import com.example.demo.model.CommonConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MQSender {
    @Autowired
    RabbitTemplate rabbitTemplate;

    public void send(String routeKey) {
        String message = "message" + new Date();
        System.out.println("Sender  " + message);
        rabbitTemplate.convertAndSend(CommonConst.MQ_EXCHANGE_NAME, routeKey, message);
    }
}
